﻿using System;
using System.Collections.Generic;
using LogSystem;
using UnityEditor;
using UnityEngine;
using Yoozoo.Framework.Core;
using Yoozoo.Gameplay.Liberty.AI;
using Yoozoo.Gta.Common;
using Yoozoo.HRP.Runtime;
using Yoozoo.Managers.ResourceManagerV2.Runtime;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    [CustomEditor(typeof(StreetEventHittableTargetLine))]
    public class StreetEventHittableTargetLineEditor : UnityEditor.Editor
    {
        // 自身组件
        private StreetEventHittableTargetLine _Target;
    
        void OnEnable()
        {
            _Target = this.target as StreetEventHittableTargetLine;
        }

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            
            if (GUILayout.Button("刷新控制点"))
            {
                _Target._startPoint = _Target.transform.Find("controlPoint/start");
                _Target._endPoint = _Target.transform.Find("controlPoint/end");
                _Target._spawnPoints.Clear();
                foreach(Transform spawnPoint in _Target.transform.Find("controlPoint"))
                {
                    if (spawnPoint == _Target._startPoint || spawnPoint == _Target._endPoint)
                    {
                        continue;
                    }
                    _Target._spawnPoints.Add(spawnPoint);
                }
            }
        }
        
    }
}